package net.pugsplace.gpremacy.rules.loaders;

import net.pugsplace.gpremacy.rules.RuleSet;
import net.pugsplace.gpremacy.rules.UnitType;
import net.pugsplace.gpremacy.state.ResourceTuple;

public class RuleLoaders {
	public static void main(String[] args) {
		RuleSet rs = new RuleLoaders().loadRuleset("rules/test.py");

		System.out.println("Ruleset " + rs.toString());
		for (UnitType u : rs.getUnits()) {
			System.out.println(u.getType());
			System.out.print("\tUpkeep: ");
			for (ResourceTuple rt : u.getUpkeepCost())
				System.out.print(rt + " ");
			System.out.print("\n\tBuild cost: ");
			for (ResourceTuple rt : u.getBuildCost())
				System.out.print(rt + " ");
			System.out.println();
		}
	}

	private final RuleLoader[] loaders = new RuleLoader[] { new PythonRuleLoader() };

	public RuleSet loadRuleset(String path) {
		for (RuleLoader loader : loaders) {
			if (loader.canLoad(path)) {
				return loader.loadRuleset(path);
			}
		}
		return null;
	}
}
